{include file="common/header"}
{include file="common/footer"}
<body class="pear-container">
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
        <div class="layui-card">
            <form class="layui-form edit-form" method="post" action="">
                <div class="layui-tab layui-tab-brief" lay-filter="TabBrief">
                    <ul class="layui-tab-title">
                        <li class="layui-this">基础设置</li>
                        <li>链接设置</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    网站标题
                                </label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input" name="title"
                                           value="{$data['title']??''}" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    网站LOGO
                                </label>
                                <div class="layui-input-block">
                                    {Upfile:uploadtag tagid='logo' name="logo" url="$data['logo']??[]" dir="config"/}
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">
                                    登录验证码
                                </label>
                                <div class="layui-input-block">
                                    {if $data['login_captcha'] == 1}
                                    <input type="radio" name="login_captcha" value="1" title="开启" checked>
                                    <input type="radio" name="login_captcha" value="0" title="关闭">
                                    {else}
                                    <input type="radio" name="login_captcha" value="1" title="开启">
                                    <input type="radio" name="login_captcha" value="0" title="关闭" checked>
                                    {/if}
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <div class="layui-form-item">
                                <label class="layui-form-label">生成位数(位)</label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input" name="code_number"
                                           value="{$data['code_number']??'6'}" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">链接时长(天)</label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input" name="expire_time"
                                           value="{$data['expire_time']??'999'}" type="text"/>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">API生成</label>
                                <div class="layui-input-block">
                                    {if $data['api_generate']??0}
                                    <input type="radio" name="api_generate" value="1" title="开启" checked>
                                    <input type="radio" name="api_generate" value="0" title="关闭">
                                    {else}
                                    <input type="radio" name="api_generate" value="1" title="开启">
                                    <input type="radio" name="api_generate" value="0" title="关闭" checked>
                                    {/if}
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">生成密码</label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input" placeholder="留空则不验证密码"
                                           name="generate_pwd" value="{$data['generate_pwd']??''}" type="text"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-input-block" style="min-height: 80px;">
                    <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit=""
                            lay-filter="save">
                        <i class="layui-icon layui-icon-ok"></i>
                        提交
                    </button>
                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(save)', function (data) {
            $.ajax({
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (res) {
                    //判断有没有权限
                    if (res && res.code == 999) {
                        layer.msg(res.msg, {
                            icon: 5,
                            time: 2000,
                        })
                        return false;
                    } else if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1, time: 1000}, function () {
                            location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });


        form.on('radio(type)', function (data) {
            if (data.value == 1) {
                $("#oss").hide();
                $("#qiniu").hide();
            }
            if (data.value == 2) {
                $("#oss").show();
                $("#qiniu").hide();
            }
            if (data.value == 3) {
                $("#qiniu").show();
                $("#oss").hide();
            }
        });
    })
</script>
</body>
</html>
